package org.ricks.game;

import org.ricks.game.handler.WSHandler;
import org.ricks.game.rpc.GameRpcHandler;
import org.ricks.ioc.RicksContext;
import org.ricks.net.Protocol;
import org.ricks.net.action.parser.ProtocolParserEnum;
import org.ricks.net.action.protocol.DefInnerProtocol;
import org.ricks.net.http.server.HttpBootstrap;
import org.ricks.net.http.server.handler.WebSocketRouteHandler;
import org.ricks.net.transport.AioQuickServer;

import java.io.IOException;
import java.net.StandardSocketOptions;

public class GameStarterB {

    public static void main(String[] args) throws IOException {
        RicksContext.me().init();
        //4. 启动对内服务
        Protocol protocol = new DefInnerProtocol(ProtocolParserEnum.STRING.getParser());
        AioQuickServer server = new AioQuickServer(8888,protocol, new GameRpcHandler());
        server.setThreadNum(32)                          // 32 线程（32 核机器）
                .setReadBufferSize(64 * 1024)              // 64KB 读缓冲
                .setWriteBuffer(64 * 1024, 2048)           // 32KB/块，总容量 64MB
                .setBacklog(8192)                          // 应对突发连接
                .setOption(StandardSocketOptions.SO_RCVBUF, 256 * 1024)
                .disableLowMemory();                       // 优先吞吐量
        server.start();
    }
}
